package com.ruizhong.PIW.controller;

import com.ruizhong.PIW.entity.TDisplay;
import com.ruizhong.PIW.service.DisplayService;
import com.ruizhong.PIW.utils.DLLTEST;
import com.ruizhong.PIW.utils.FaceUtil;
import com.ruizhong.PIW.utils.Result;
import com.ruizhong.PIW.utils.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/display")
@CrossOrigin
@Slf4j
public class DisplayController {
    @Autowired
    private DisplayService displayService;
    @PostMapping("/submitUpdate")
    public Result submitUpdate(@RequestBody TDisplay tDisplay){
        displayService.submitUpdate(tDisplay);
        return new Result<>(ResultCode.success,"保存成功",null);
    }
    @GetMapping("/getDisplayInfo")
    public Result getDisplayInfo(){
        TDisplay tDisplay=displayService.getDisplayInfo();
        return new Result<>(ResultCode.success,null,tDisplay);
    }

    @PostMapping("/updateDisplayInfo")
    public Result updateDisplayInfo(@RequestBody TDisplay tDisplay){
        displayService.updateDisplayInfo(tDisplay);
        return new Result(ResultCode.success,null,null);
    }

    @GetMapping("/testOpencv")
    public Result testOpencv(){
        FaceUtil.INSTANCE.Run();
//        List list = FaceUtil.INSTANCE.GetImage();
//        FaceUtil.INSTANCE.test();

        return new Result(ResultCode.success,null,null);
    }

    @GetMapping("/dllTest")
    public Result dllTest(){
        String s = DLLTEST.INSTANCE.GetType();
        System.out.println(s);
        String key1 = "happy";
        s = DLLTEST.INSTANCE.SGSoftRegiste(key1);
        System.out.println(s);
        return new Result(ResultCode.success,null,null);
    }
}
